<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/12/30
 * Time: 15:43
 */

namespace app\adminapiv3\service;


use think\Db;

class ServerSystemLog extends Base
{
    /**
     * @name 列表
     * @param $params
     * @param $limit
     * @return array
     * @author wx
     * @date 2020/12/30 15:49
     */
    public function list($params, $limit)
    {
        //修改状态
        Db::name('server_system_log')->where('status', 0)->update(['status' => 1]);

        $condition = [];
        if(!empty($params['content'])){
            $condition[] = ['content', 'like', '%'.$params['content'].'%'];
        }
        if(!empty($params['ctime'])){
            $startTime = strtotime($params['ctime']);
            $condition[] = ['ctime', 'between', [$startTime, $startTime + 86399]];
        }
        if(is_numeric($params['status'])){
            $condition[] = ['status', 'eq', $params['status']];
        }

        return Db::name('server_system_log')->order('id desc')->where($condition)->paginate($limit)->toArray();
    }
}